<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>搜索页面</title>
</head>
<body>
		<input type="text"  id="keyword" onkeyup="match()"/>
		<input type="button" value="查找" width="50px"/>
		
		<table id="show">
			
		</table>
	<script type="text/javascript">

		function match(){
			var xhr = new XMLHttpRequest();
			var search = document.getElementById("keyword");
			var name= search.value;
			var table=document.getElementById("show");
		    table.innerHTML="";
		    xhr.open("GET","search?keyword="+name);
		    xhr.onreadystatechange=function(){
		        if(xhr.status==200&&xhr.readyState==4){
		            var areas = JSON.parse(xhr.responseText);
		            if(areas.length!=0){
		                areas.forEach((item)=>{
		                	
		                	let tr= document.createElement("tr");
		                	let td= document.createElement("td");
		                	td.innerHTML = item.area;
		                	tr.appendChild(td);
		                	table.appendChild(tr);
		                });
		            }
		        }
		    };
		    xhr.send(null);
		}
</script>
</body>
</html>